<!--
  - ControllerOtherAnalysis.php
  - v1.3
  - 4/02/2011
  -->

<!--
  - Code Specifications:
  - This code processes the inputs of the user in ViewOtherAnalysis.php
  - This also stores the inputs, mean, and standard deviation into the 
  - database table.
  -->
	
<?php
	//Gets required libraries
	require '../libraries/EditAnalysisLib.php';
	require '../libraries/ComputeAnalysisLib.php';
	require '../libraries/UserLibrary.php';
	
	//Formally starts session
	session_start();
	
	//Ensures that the analyst is logged in.
	if(isSessionSet("analyst", NULL, "../Logout.php"));
	
	//Gathers data input from ViewOtherAnalysis.php
	$hidden1 = $_POST["value1"];
	$hidden2 = $_POST["value2"];
	$hidden3 = $_POST["value3"];
	$val1 = $_POST["$hidden1"];
	$val2 = $_POST["$hidden2"];
	$val3 = $_POST["$hidden3"];
	$check = $_POST["value"];
	$ctr = 0;
	if (isset($check) == true){
		$ctr = count($check);
	}
	
	//Computes mean and standard deviation from other analysis.
	if (isset($_POST['save'])) {
		$mean = ComputeMean($val1, $val2, $val3, $ctr);
		$standardDeviation = ComputeStandardDeviationOthers($val1, $val2,
				$val3, $mean, $ctr);
		$edit = editOthers($mean, $standardDeviation, "result_value1",
				$val1, "result_value2", $val2,  "result_value3", $val3, 
				$_SESSION["year"], $_SESSION["no"], "casl", "localhost",
				"editanalysis", "editanalysis");
	} 	
	
	//Redirect to ViewOtherAnalysis.php
	header("Location: ViewOtherAnalysis.php");
?>